package com.jt.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.jt.pojo.Item;
import com.jt.pojo.ItemDesc;
import com.jt.service.DubboItemService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class ItemController {

    @Reference(check = false)//启动时是否校验有服务提供者
    private DubboItemService itemService;

    /**
     * 实现商品的展现
     */
    @RequestMapping("items/{itemId}")
    public String findItemById(@PathVariable Long itemId, Model model){

        Item item=itemService.findItemById(itemId);
        ItemDesc itemDesc=itemService.findItemDescById(itemId);
        model.addAttribute("item", item);
        model.addAttribute("itemDesc", itemDesc);
        return "item";
    }
}
